using System.ComponentModel.DataAnnotations;

namespace RAG.Domain.Entities.App;

public class Users : EntityBase
{
   public Guid Id { get; set; } //用户id
   
   [StringLength(50, MinimumLength = 3, ErrorMessage = "用户名长度必须在3-50个字符之间")]
   public string Username { get; set; } = null!; //用户名(3-50字符)
   
   [StringLength(255, ErrorMessage = "密码长度不能超过255个字符")]
   public string Password { get; set; } = null!; //加密后的密码
   
   [StringLength(60, ErrorMessage = "密码盐长度不能超过60个字符")]
   public string Salt { get; set; } = null!; //密码盐(BCrypt生成的盐值，通常为60个字符)
   
   [StringLength(100, ErrorMessage = "邮箱长度不能超过100个字符")]
   [EmailAddress(ErrorMessage = "邮箱格式不正确")]
   public string Email { get; set; } = null!; //邮箱地址
   
   [StringLength(20, ErrorMessage = "手机号长度不能超过20个字符")]
   [Required(ErrorMessage = "手机号不能为空")]
   public string Phone { get; set; } = null!; //手机号
   
   [StringLength(255, ErrorMessage = "头像URL长度不能超过255个字符")]
   public string? Avatar { get; set; } //头像URL
   
   public int AccountStatus { get; set; } = 0; //0=正常，1=临时锁定(自动解锁)，2=管理员手动禁用
   public int FailedLoginAttempts { get; set; } = 0; //连续登录失败计数器，成功登录后重置为0
   public DateTime? LockedUntil { get; set; } //锁定时间
   public DateTime? LastFailedLogin { get; set; } //最后一次登录失败的时间
   public DateTime? LastActivityTime { get; set; } //最后一次操作时间
   public DateTime? LastLoginTime { get; set; } //最后一次登录时间
   
   // 导航属性
   public ICollection<Role> Roles { get; set; } = new List<Role>();
   public ICollection<Session> Sessions { get; set; } = new List<Session>();
   public ICollection<Conversation> Conversations { get; set; } = new List<Conversation>();
   public ICollection<KnowledgeBase> KnowledgeBases { get; set; } = new List<KnowledgeBase>();
   public ICollection<Document> Documents { get; set; } = new List<Document>();
}